|
|
|
|
|
|
|
requirements, the controller class CApplication enforces these preferences in conjunction with the Graphical User Interface subsystem. You can record these preferences to a database, a regular file, an INI (initialization) file, or the Registry. |
|
|
|
|
|
|
|
|
Using the Windows 95 Registry and Visual Basic |
|
|
|
|
|
|
|
|
If you plan to use the Registry to record user preferences and possibly application transaction information, you need a class for this. In Visual Basic, you create a facade class called RegistryFacade. Recall that a facade class is one that is literally a facade for encapsulating function calls, particularly those associated with legacy systems or APIs. In this context, the class RegistryFacade encapsulates the calls to the Registry functions that Visual Basic supports. Listing 14.1 shows the code in this class that you might implement. |
|
|
|
|
|
|
|
|
LISTING 14.1. THE CODE LISTING FOR THE CLASSRegistryFacade. |
|
|
|
 |
|
|
|
|
1: VERSION 1.0 CLASS
2: BEGIN
3: MultiUse = 0 'False
4: END
5: Attribute VB_Name = $ldquo;RegistryFacade$rdquo;
6: Attribute VB_GlobalNameSpace = False
7: Attribute VB_Creatable = True
8: Attribute VB_PredeclaredId = False
9: Attribute VB_Exposed = False
10:
11: 'Used as default for getRegSetting method
12: 'if no argument values are passed in. Populated
13: 'in saveRegSetting method
14: Private m_pLastAppName As String
15: Private m_pLastSection As String
16: Private m_pLastKey As String, m_pCurrentKey As String
17: Private m_returns
18:
19:
20: Public Function saveRegSetting(argAppName As String, _
21: argSection As String, argKey As String, argSetting)
22: 'Populate module-level variables as default for
23: 'getRegSetting method
24: Dim returns
25: m_pLastAppName = argAppName
26: m_pLastSection = argSection
27: m_pLastKey = argKey
28: SaveSetting AppName:=argAppName, section:=argSection, _
29: Key:=argKey, setting:=argSetting
30:
31: End Function
32:
|
|
|
|
|
|